import InteractiveBase from "../../../LevelCommon/InteractiveBase";
import { utils } from "../../../../utils/CommonUtil";

export default class RotateCommon extends InteractiveBase{
     /** 每次旋转度数*/
     public  rotateAngle:number;
     public  isY:boolean = false;
     public  isX:boolean = false;
     public  curIndex:number = 0;
     private  totalIndex:number;
     /** 音效名字*/
     public  voiceName:string;
     private mowner:Laya.Sprite3D;
     onStart()
     {
         this.mowner = this.owner as Laya.Sprite3D;
         this.totalIndex = Math.floor(360 / this.rotateAngle);
     }
     protected InteractiveLogic():boolean
     {
         if(utils.CommonUtils.isMeaningfulString(this.voiceName))
         {
             window.gameFacade.SoundMng.playSound(this.voiceName);
         }
         if (this.isY)
         {
            this.mowner.transform.rotate(new Laya.Vector3(0, this.rotateAngle,0),true,false);
         }
         else if (this.isX)
         {
            this.mowner.transform.rotate(new Laya.Vector3(this.rotateAngle,0,0),true,false);
         }
         else
         {
            this.mowner.transform.rotate(new Laya.Vector3(0,0,this.rotateAngle),true,false);
         }
         this.curIndex++;
         this.curIndex = this.curIndex % this.totalIndex;
         this.CallToLevel(this.owner.name + "_Rotate");
         return false;
     }
}